/////////////////////////////////////////////////////////////////////////////
//
// (c) 2007 BinaryComponents Ltd.  All Rights Reserved.
//
// http://www.binarycomponents.com/
//
/////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace BinaryComponents.Utility.Win32
{
	[Flags]
	[CLSCompliant( false )]
	public enum WindowStyles : uint
	{
		WS_OVERLAPPED = 0x00000000,
		WS_POPUP = 0x80000000,
		WS_CHILD = 0x40000000,
		WS_MINIMIZE = 0x20000000,
		WS_VISIBLE = 0x10000000,
		WS_DISABLED = 0x08000000,
		WS_CLIPSIBLINGS = 0x04000000,
		WS_CLIPCHILDREN = 0x02000000,
		WS_MAXIMIZE = 0x01000000,
		WS_BORDER = 0x00800000,
		WS_DLGFRAME = 0x00400000,
		WS_VSCROLL = 0x00200000,
		WS_HSCROLL = 0x00100000,
		WS_SYSMENU = 0x00080000,
		WS_THICKFRAME = 0x00040000,
		WS_GROUP = 0x00020000,
		WS_TABSTOP = 0x00010000,

		WS_MINIMIZEBOX = 0x00020000,
		WS_MAXIMIZEBOX = 0x00010000,

		WS_CAPTION = WS_BORDER | WS_DLGFRAME,
		WS_TILED = WS_OVERLAPPED,
		WS_ICONIC = WS_MINIMIZE,
		WS_SIZEBOX = WS_THICKFRAME,
		WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW,

		WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
		WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU,
		WS_CHILDWINDOW = WS_CHILD,
	}

	[Flags]
	[CLSCompliant( false )]
	public enum WindowStylesEx : uint
	{
		WS_EX_DLGMODALFRAME = 0x00000001,
		WS_EX_NOPARENTNOTIFY = 0x00000004,
		WS_EX_TOPMOST = 0x00000008,
		WS_EX_ACCEPTFILES = 0x00000010,
		WS_EX_TRANSPARENT = 0x00000020,
		WS_EX_MDICHILD = 0x00000040,
		WS_EX_TOOLWINDOW = 0x00000080,
		WS_EX_WINDOWEDGE = 0x00000100,
		WS_EX_CLIENTEDGE = 0x00000200,
		WS_EX_CONTEXTHELP = 0x00000400,
		WS_EX_RIGHT = 0x00001000,
		WS_EX_LEFT = 0x00000000,
		WS_EX_RTLREADING = 0x00002000,
		WS_EX_LTRREADING = 0x00000000,
		WS_EX_LEFTSCROLLBAR = 0x00004000,
		WS_EX_RIGHTSCROLLBAR = 0x00000000,
		WS_EX_CONTROLPARENT = 0x00010000,
		WS_EX_STATICEDGE = 0x00020000,
		WS_EX_APPWINDOW = 0x00040000,

		WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE),
		WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST),

		WS_EX_LAYERED = 0x00080000,

		WS_EX_NOINHERITLAYOUT = 0x00100000,
		WS_EX_LAYOUTRTL = 0x00400000,

		WS_EX_COMPOSITED = 0x02000000,
		WS_EX_NOACTIVATE = 0x08000000,
	}

	[Flags]
	public enum ClassStyle
	{
		CS_DROPSHADOW = 0x00020000
	}

	public enum RegionValue
	{
		ERROR             =0,
		NULLREGION        =1,
		SIMPLEREGION      =2,
		COMPLEXREGION     =3,
		RGN_AND           =1		
	}

	public enum NCHITTEST
	{
		HTTRANSPARENT = -1,
		HTNOWHERE = 0,
		HTCLIENT = 1,
		HTCAPTION = 2,
		HTSYSMENU = 3,
		HTGROWBOX = 4,
		HTSIZE = HTGROWBOX,
		HTMENU = 5,
		HTHSCROLL = 6,
		HTVSCROLL = 7,
		HTMINBUTTON = 8,
		HTMAXBUTTON = 9,
		HTLEFT = 10,
		HTRIGHT = 11,
		HTTOP = 12,
		HTTOPLEFT = 13,
		HTTOPRIGHT = 14,
		HTBOTTOM = 15,
		HTBOTTOMLEFT = 16,
		HTBOTTOMRIGHT = 17,
		HTBORDER = 18,
		HTREDUCE = HTMINBUTTON,
		HTZOOM = HTMAXBUTTON,
		HTSIZEFIRST = HTLEFT,
		HTSIZELAST = HTBOTTOMRIGHT,
		HTOBJECT = 19,
		HTCLOSE = 20,
		HTHELP = 21,
	}

	[Flags]
	public enum SetWindowPosOptions
	{
		SWP_NOSIZE = 0x0001,
		SWP_NOMOVE = 0x0002,
		SWP_NOZORDER = 0x0004,
		SWP_NOREDRAW = 0x0008,
		SWP_NOACTIVATE = 0x0010,
		SWP_FRAMECHANGED = 0x0020,	/* The frame changed: send WM_NCCALCSIZE */
		SWP_SHOWWINDOW = 0x0040,
		SWP_HIDEWINDOW = 0x0080,
		SWP_NOCOPYBITS = 0x0100,
		SWP_NOOWNERZORDER = 0x0200,	/* Don't do owner Z ordering */
		SWP_NOSENDCHANGING = 0x0400		/* Don't send WM_WINDOWPOSCHANGING */
	}

	[Flags()]
	public enum DCX
	{
		DCX_CACHE = 0x2,
		DCX_CLIPCHILDREN = 0x8,
		DCX_CLIPSIBLINGS = 0x10,
		DCX_EXCLUDERGN = 0x40,
		DCX_EXCLUDEUPDATE = 0x100,
		DCX_INTERSECTRGN = 0x80,
		DCX_INTERSECTUPDATE = 0x200,
		DCX_LOCKWINDOWUPDATE = 0x400,
		DCX_NORECOMPUTE = 0x100000,
		DCX_NORESETATTRS = 0x4,
		DCX_PARENTCLIP = 0x20,
		DCX_VALIDATE = 0x200000,
		DCX_WINDOW = 0x1,
	}

	public enum ShowWindowOptions
	{
		SW_HIDE = 0,
		SW_SHOWNORMAL = 1,
		SW_NORMAL = 1,
		SW_SHOWMINIMIZED = 2,
		SW_SHOWMAXIMIZED = 3,
		SW_MAXIMIZE = 3,
		SW_SHOWNOACTIVATE = 4,
		SW_SHOW = 5,
		SW_MINIMIZE = 6,
		SW_SHOWMINNOACTIVE = 7,
		SW_SHOWNA = 8,
		SW_RESTORE = 9,
		SW_SHOWDEFAULT = 10,
		SW_FORCEMINIMIZE = 11
	}

	[Flags]
	public enum RedrawWindowOptions
	{
		RDW_INVALIDATE = 0x0001,
		RDW_INTERNALPAINT = 0x0002,
		RDW_ERASE = 0x0004,
		RDW_VALIDATE = 0x0008,
		RDW_NOINTERNALPAINT = 0x0010,
		RDW_NOERASE = 0x0020,
		RDW_NOCHILDREN = 0x0040,
		RDW_ALLCHILDREN = 0x0080,
		RDW_UPDATENOW = 0x0100,
		RDW_ERASENOW = 0x0200,
		RDW_FRAME = 0x0400,
		RDW_NOFRAME = 0x0800
	}

	public enum SystemCommands
	{
		SC_SIZE = 0xF000,
		SC_MOVE = 0xF010,
		SC_MINIMIZE = 0xF020,
		SC_MAXIMIZE = 0xF030,
		SC_MAXIMIZE2 = 0xF032,	// fired from double-click on caption
		SC_NEXTWINDOW = 0xF040,
		SC_PREVWINDOW = 0xF050,
		SC_CLOSE = 0xF060,
		SC_VSCROLL = 0xF070,
		SC_HSCROLL = 0xF080,
		SC_MOUSEMENU = 0xF090,
		SC_KEYMENU = 0xF100,
		SC_ARRANGE = 0xF110,
		SC_RESTORE = 0xF120,
		SC_RESTORE2 = 0xF122,	// fired from double-click on caption
		SC_TASKLIST = 0xF130,
		SC_SCREENSAVE = 0xF140,
		SC_HOTKEY = 0xF150,

		SC_DEFAULT = 0xF160,
		SC_MONITORPOWER = 0xF170,
		SC_CONTEXTHELP = 0xF180,
		SC_SEPARATOR = 0xF00F
	}

	[Flags]
	public enum PeekMessageOptions
	{
		PM_NOREMOVE = 0x0000,
		PM_REMOVE = 0x0001,
		PM_NOYIELD = 0x0002
	}

	public enum SizingOptions
	{
		WMSZ_LEFT = 1,
		WMSZ_RIGHT = 2,
		WMSZ_TOP = 3,
		WMSZ_TOPLEFT = 4,
		WMSZ_TOPRIGHT = 5,
		WMSZ_BOTTOM = 6,
		WMSZ_BOTTOMLEFT = 7,
		WMSZ_BOTTOMRIGHT = 8
	}

	[StructLayout( LayoutKind.Sequential )]
	[CLSCompliant( false )]
	public struct WINDOWPOS
	{
		public IntPtr hwnd;
		public IntPtr hWndInsertAfter;
		public int x;
		public int y;
		public int cx;
		public int cy;
		public uint flags;
	}

	[StructLayout( LayoutKind.Sequential )]
	[CLSCompliant( false )]
	public struct NCCALCSIZE_PARAMS
	{
		/// <summary>
		/// Contains the new coordinates of a window that has been moved or resized, that is, it is the proposed new window coordinates.
		/// </summary>
		public Common.RECT rectProposed;
		/// <summary>
		/// Contains the coordinates of the window before it was moved or resized.
		/// </summary>
		public Common.RECT rectBeforeMove;
		/// <summary>
		/// Contains the coordinates of the window's client area before the window was moved or resized.
		/// </summary>
		public Common.RECT rectClientBeforeMove;
		/// <summary>
		/// Pointer to a WINDOWPOS structure that contains the size and position values specified in the operation that moved or resized the window.
		/// </summary>
		public WINDOWPOS lpPos;
	}

	public enum INPUTTYPE
	{
		MOUSE = 0,
		KEYBOARD = 1,
		HARDWARE = 2
	}

	[StructLayout( LayoutKind.Sequential )]
	public struct MOUSEINPUT
	{
		public int dx;
		public int dy;
		public int mouseData;
		public int dwFlags;
		public int time;
		public IntPtr dwExtraInfo;
	}

	[StructLayout( LayoutKind.Sequential )]
	public struct KEYBDINPUT
	{
		public short wVk;
		public short wScan;
		public int dwFlags;
		public int time;
		public IntPtr dwExtraInfo;
	}

	[StructLayout( LayoutKind.Sequential )]
	public struct HARDWAREINPUT
	{
		public int uMsg;
		public short wParamL;
		public short wParamH;
	}

	[StructLayout( LayoutKind.Explicit )]
	public struct INPUT
	{
		[FieldOffset( 0 )]
		public INPUTTYPE type;
		[FieldOffset( 4 )]
		public MOUSEINPUT mi;
		[FieldOffset( 4 )]
		public KEYBDINPUT ki;
		[FieldOffset( 4 )]
		public HARDWAREINPUT hi;
	}

	[StructLayout( LayoutKind.Sequential )]
	public struct WINDOWPLACEMENT
	{
		public int length;
		public int flags;
		public ShowWindowOptions showCmd;
		public Common.POINT ptMinPosition;
		public Common.POINT ptMaxPosition;
		public Common.RECT rcNormalPosition;

		public static WINDOWPLACEMENT Default
		{
			get
			{
				WINDOWPLACEMENT result = new WINDOWPLACEMENT();

				result.length = Marshal.SizeOf( result );

				return result;
			}
		}
	}
}
